package com.osleague.demo.dao;

import com.osleague.demo.domain.User;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created by Yif Zhan on 2015/10/29.
 */
@Repository
public class UserDao {

    @Resource
    private SessionFactory sessionFactory;

    public User getUserById(long id) {
        return sessionFactory.openSession().get(User.class, id);
    }

    @Transactional
    public void addUser(User user) {
        sessionFactory.openSession().save(user);
    }


}
